/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2013
 */

package com.smg.community.dao;

import java.util.*;

import javacommon.base.*;
import javacommon.util.*;

import cn.org.rapid_framework.util.*;
import cn.org.rapid_framework.web.util.*;
import cn.org.rapid_framework.page.*;
import cn.org.rapid_framework.page.impl.*;

import com.smg.community.model.*;
import com.smg.community.dao.*;
import com.smg.community.service.*;
import com.smg.community.vo.query.*;

/**
 * @author badqiu email:badqiu(a)gmail.com
 * @version 1.0
 * @since 1.0
 */


import org.springframework.stereotype.Repository;


@Repository
public class SmgGroupDao extends BaseIbatis3Dao<SmgGroup,java.lang.Integer>{
	
	@Override
	public String getIbatisMapperNamesapce() {
		return "SmgGroup";
	}
	
	public void saveOrUpdate(SmgGroup entity) {
		if(entity.getGroupId() == null) 
			save(entity);
		else 
			update(entity);
	}
	
	public Page findPage(SmgGroupQuery query) {
		return pageQuery("SmgGroup.findPage",query);
	}

	public List<SmgGroup> getByQuery(SmgGroupQuery groupQuery) {
		return this.getSqlSessionTemplate().selectList("SmgGroup.getByQuery", groupQuery );
	}

	public List<SmgGroup>  getSevenHotGroupList(int cityNo) {
		return this.getSqlSessionTemplate().selectList("SmgGroup.getSevenHotGroupList", cityNo );
	}

	public List<SmgGroup> getByMemberId(int memberId, int size) {
		Map<String,String> map = new HashMap<String,String>();
		map.put("memberId",memberId+"");
		map.put("limit",size+"");
		return this.getSqlSessionTemplate().selectList("SmgGroup.getByMemberId", map );
	}

	public Page<SmgGroup> findMemberJoinPage(SmgGroupQuery query) {
		return pageQuery("SmgGroup.findMemberJoinPage",query);
	}

	public int getMemberJoinGroupCount(Integer memberId) {
		return (Integer)this.getSqlSessionTemplate().selectOne("SmgGroup.getMemberJoinGroupCount", memberId);
	}

	public int getMemberMastetGroupCount(Integer memberId) {
		return (Integer)this.getSqlSessionTemplate().selectOne("SmgGroup.getMemberMastetGroupCount", memberId);
	}

	public void addMemberCount(int groupId) {
		this.getSqlSessionTemplate().selectOne("SmgGroup.addMemberCount", groupId);
	}

	public void subMemberCount(int groupId) {
		this.getSqlSessionTemplate().selectOne("SmgGroup.subMemberCount", groupId);
	}
	

}
